<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ include file="/basecore/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>app</title>
		<%@ include file="/basecore/meta.jsp"%>	
		<script type="text/javascript" src="${contextPath}/dwr/interface/UsernameChecker.js"></script>		
		<script>
			function checkpassword(){
				if(typeof document.appForm.password=='object'){
				if(document.appForm.password.value!=document.appForm.password2.value){
					document.getElementById("passworderror").innerHTML="两次输入的密码必须一致";
					return false;
				}else{			
					document.getElementById("passworderror").innerHTML="";
					return true;
				}
				}else{
				return true;
				}
				
			}	
			function removeErrorSpan(username){
				var span=document.getElementById("username__ErrorMessagePanel");				
				if(span !=null){					
					username.parentNode.removeChild(span);
				}
			}
			function checkusername(username,errorflag){
				UsernameChecker.check(username.value,function(data){
					if(data!=null){
						errorflag.value="1";
						var span=document.createElement("SPAN")
						span.id = "username__ErrorMessagePanel";
						span.style.color = "red";
						span.innerHTML=data;
						username.parentNode.appendChild(span);
					}
				});
			}
		</script>
	</head>
	<body class="content">		
		<form name="appForm" id="appForm" action="userController!store.wit"	method="post">
			<input name="errorflag" id="errorflag" type="hidden" />
			<input name="_hdiv_ignoreParameters" value="email"/>
			<div align=right class="fix-operation">
				<a href="#" onclick="if(getObject('errorflag').value==''){new validator().validate(appForm,3);}" accesskey="s" title="保存数据">
					<img src="${contextPath}/webresource/images/toolbar/save.png">
					保存(S)</a>
				<a href="javascript:document.appForm.reset();" accesskey="r"
					title="取消更改"> <img src="${contextPath}/webresource/images/toolbar/clear.gif">
					取消更改(R)</a>
				<a href="userController.wit" accesskey="b"> <img
						src="${contextPath}/webresource/images/toolbar/return_to_list.jpeg"
						title="返回上一页"> 返回(B)</a>
			</div>
			<input type="hidden" name="id" value="${data.id}">
			<div id="editFormDiv" style="margin-left: 30px; margin-top: 30px;">
				<table border=0 width="100%" class="formtable"	style="MARGIN-TOP: 30px;">
					
						<tr class="table-tr-odd">
							<td>
								<label for="username">
									用户名												
								</label>
							</td>
							<td>
								<input name="username" value="${data.username}" class="input-password"
								dataType="English" require="true" msg="用户名只允许英文字母和数字组成"
								onchange="removeErrorSpan(this);if(this.value!='${data.username}')checkusername(this,document.appForm.errorflag)">
							</td>
						</tr>
						<tr class="table-tr-odd">
							<td>
								<label for="name">
									真实姓名
								</label>
							</td>
							<td>
								<input name="name" value="${data.name}" class="input-password"
								dataType="Chinese" msg="真实姓名只允许中文"
								>
							</td>
						</tr>
						<tr class="table-tr-odd">
							<td>
								<label for="name">
									性别
								</label>
							</td>
							<td>
								<select name="sex">									
									<option value="男" ${data.sex=="男"?"selected":""}>男</option>
									<option value="女" ${data.sex=="女"?"selected":""}>女</option>
								</select>								
							</td>
						</tr>
						<tr class="table-tr-odd">
							<td>
								<label for="password2">
									EMAIL
								</label>
							</td>
							<td>
								<input type="text" name="email" value="${data.email}">${data.email}
							</td>
						</tr>
						<tr class="table-tr-odd">
							<td>
								<label for="password">
									密码
								</label>
							</td>
							<td>
								<input type="password" name="password" value="${data.password}"
								dataType="LimitB" msg="密码不符合安全规则，只允许英文字母和数字组成"
								class="input-password"
								>
								<span id="passworderror" name="passworderror"></span>
							</td>
						</tr>
						<tr class="table-tr-odd">
							<td>
								<label for="password2">
									重复密码
								</label>
							</td>
							<td>
								<input type="password" name="password2" value="${data.password}"
								dataType="Repeat" to="password" msg="两次输入的密码不一致"
								class="input-password">
							</td>
						</tr>
						
				</table>
			</div>
		</form>		
	</body>
</html>
